home *** CD-ROM | disk | FTP | other *** search
- property mySpr, mass, velocity, location, timeScale, scale, systemOrigin, frozen, activated, animCount, myAnim, flyMass, pSoftSound, pHardSound
- global stageWidth, stageHeight
-
- on new me, thisSpr, thisAnim, thisSound
- mySpr = thisSpr
- myAnim = thisAnim
- timeScale = 50
- scale = 5
- pSoftSound = 0
- pHardSound = 0
- if thisSound then
- pSoftSound = thisSound
- pHardSound = thisSound + 1
- end if
- stageWidth = the stageRight - the stageLeft
- stageHeight = the stageBottom - the stageTop
- systemOrigin = [#x: stageWidth / 2, #Y: stageHeight / 2]
- frozen = 0
- activated = 0
- mass = 65
- flyMass = 100
- velocity = [#x: 0, #Y: 0]
- setloc(me)
- return me
- end
-
- on setloc me
- newX = (the locH of sprite mySpr - systemOrigin.x) * scale
- newY = (the locV of sprite mySpr - systemOrigin.Y) * scale
- location = [#x: newX, #Y: newY]
- end
-
- on gravitate me
- mouseMass = mass / 2
- flymouseMass = flyMass / 4
- if mySpr = 12 then
- N = flyGravity(mySpr, flyMass, point(the mouseH, the mouseV), flymouseMass, 0, "attract")
- else
- N = calcGravity(mySpr, mass)
- end if
- push(me, N)
- end
-
- on push me, theForce
- acceleration = theForce / mass
- deltaVelocity = acceleration * timeScale
- velocity = velocity + deltaVelocity
- playSound = 0
- if the bottom of sprite mySpr > stageHeight then
- if velocity.Y > 0 then
- velocity.Y = -velocity.Y
- playSound = 1
- end if
- end if
- if the top of sprite mySpr < 0 then
- if velocity.Y < 0 then
- velocity.Y = -velocity.Y
- playSound = 1
- end if
- end if
- if the left of sprite mySpr < 0 then
- if velocity.x < 0 then
- velocity.x = -velocity.x
- playSound = 1
- end if
- end if
- if the right of sprite mySpr > stageWidth then
- if velocity.x > 0 then
- velocity.x = -velocity.x
- playSound = 1
- end if
- end if
- if playSound and pSoftSound and (random(2) = 2) then
- maxVeloc = max(abs(velocity.x), abs(velocity.Y))
- if maxVeloc > 300 then
- puppetSound(2, pHardSound)
- else
- puppetSound(2, pSoftSound)
- end if
- end if
- move(me)
- end
-
- on move me
- location = location + velocity
- newLocH = systemOrigin.x + (integer(location.x) / scale)
- newLocV = systemOrigin.Y + (integer(location.Y) / scale)
- set the locH of sprite mySpr to newLocH
- set the locV of sprite mySpr to newLocV
- end
-
- on animLoop me
- if animCount <> count(myAnim) then
- animCount = animCount + 1
- if animCount >= count(myAnim) then
- animCount = count(myAnim)
- end if
- set the member of sprite mySpr to member(getAt(myAnim, animCount))
- else
- if animCount = count(myAnim) then
- animCount = 0
- end if
- end if
- end
-